#include<stdio.h>
#include<stdlib.h>
#define  MAX 10 
void Qsort(int* a, int begin, int end)
{
	int pivot = begin;
	int key = a[begin];
	int left = begin;
	int right = end;
	if (begin >= end)
	{
		return;
	}
	while (left < right)
	{
		while (left<right&&key <= a[right])
		{
			right--;
		}
		a[pivot] = a[right];
		pivot = right;
		while (left<right&&key >= a[left])
		{
			left++;
		}
		a[pivot] = a[left];
		pivot = left;
	}
	pivot = left;
	a[pivot] = key;
	Qsort(a, begin, pivot-1);
	Qsort(a, pivot + 1, end);

}
int main()
{
	srand(time(NULL));
	int a[MAX];
	int left = 0;
	int right = MAX - 1;
	
	for (int i = 0; i < MAX; i++)
	{
		a[i] = rand() % 100 + 1;
	}
	Qsort(a, left, right);
	for (int i = 0; i < MAX; i++)
	{
		printf("%d ", a[i]);
	}
	return 0;
}